﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace Demo01
{
    class Program
    {
        static void Main(string[] args)
        {
            Random ran = new Random();

            while (true)
            {
                Console.WriteLine("1.随机数组 2.0~5的小数 3.4~7的小数 4.邮箱 5.电话号码");
                int key = int.Parse(Console.ReadLine());
                switch (key)
                {
                    case 1:
                        Test01();
                        break;
                    case 2:
                        Test02();
                        break;
                    case 3:
                        Test03();
                        break;
                    case 4:
                        Test04();
                        break;
                    case 5:
                        Test05();
                        break;
                    default:
                        break;
                }
            }
        }
        public static void Test01()
        {
            int[] arr = new int[10];
            while (true)
            {
                if (arr.Contains(0))
                {
                    Test(arr);
                }
                else
                {
                    break;
                }
            }
            foreach (var item in arr)
            {
                Console.Write(item + " ");
            }
        }
        public static void Test02()
        {
            Random random = new Random();
            double a = random.NextDouble();
            int b = random.Next(5);
            double c = Math.Round(a + b, 2);
            Console.WriteLine(c);
        }
        public static void Test03()
        {
            Random random = new Random();
            double a = random.NextDouble();
            int b = random.Next(4,7);
            double c = Math.Round(a + b, 2);
            Console.WriteLine(c);
        }
        public static void Test04()
        {
            Console.WriteLine("请输入你的邮箱");
            string a = Console.ReadLine();
            if (Regex.IsMatch(a,@"^\w+(\.\w)*@\w+((\.\w+))+$"))
            {
                Console.WriteLine("正确");
            }else
            {
                Console.WriteLine("错误");
            }
        }
        public static void Test05()
        {
            Console.WriteLine("请输入你的手机号码");
            string a = Console.ReadLine();
            if (Regex.IsMatch(a, @"^(\+86)?1[3-9](\d){9}$"))
            {
                Console.WriteLine("正确");
            }
            else
            {
                Console.WriteLine("错误");
            }
        }
        public static int[] Test(int[] arr)
        {
            Random ran = new Random();
            for (int i = 0; i < arr.Length; i++)
            {
                int a = ran.Next(10) + 1;
                if (arr.Contains(a))
                {
                    continue;
                }
                else
                {
                    arr[i] = a;
                }
            }
            return arr;
        }
    }
}
